import { writeFile } from 'fs/promises';
import { NotionAPI } from 'notion-client';

const notion = new NotionAPI();

async function saveNotionDataToFile(pageId) {
  const filename = `./recordMap-${pageId}.json`;

  try {
    const recordMap = await notion.getPage(pageId);
    await writeFile(filename, JSON.stringify(recordMap, null, 2));
    console.log(`Data saved successfully to ${filename}`);
  } catch (error) {
    console.error('Error fetching or saving data:', error);
  }
}


saveNotionDataToFile('2023-dee93c6b78974a9ba286e183c37b98f2');
// saveNotionDataToFile('readme-37689a9f45eb4620a50d787b2e4e4ab8');
